package com.platform.system.base;

import com.platform.common.utils.StringUtils;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author Huangkai
 */
@Data
public class BaseVO {

    /**
     * uuid
     */
    private String uid;

    /**
     * 排序
     */
    private Integer sort;

    private Integer isDel;

    private Date createTime;

    private Date updateTime;

    /** 当前记录起始索引 */
    private Integer pageNum = 1;

    /** 每页显示记录数 */
    private Integer pageSize = 10;

    /** 排序列 */
    private String orderByColumn;

    /** 排序的方向desc或者asc */
    private String isAsc = "asc";

    /** 分页参数合理化 */
    private Boolean reasonable = true;
    /**
     * 删除
     */
    private List<String> uidList;

    public String getOrderBy() {
        if (StringUtils.isEmpty(orderByColumn))
        {
            return "";
        }
        return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
    }

    public void setIsAsc(String isAsc) {
        if (StringUtils.isNotEmpty(isAsc)) {
            // 兼容前端排序类型
            if ("ascending".equals(isAsc)) {
                isAsc = "asc";
            } else if ("descending".equals(isAsc)) {
                isAsc = "desc";
            }
            this.isAsc = isAsc;
        }
    }

    public Boolean getReasonable() {
        if (StringUtils.isNull(reasonable)) {
            return Boolean.TRUE;
        }
        return reasonable;
    }

    public void setReasonable(Boolean reasonable) {
        this.reasonable = reasonable;
    }
}
